import pytest
import sqlite3

@pytest.fixture(scope="class")
def connect():
    conn = sqlite3.connect('funds.db')
    print("数据库连接成功")
    yield conn
    conn.close()
    print("数据库连接关闭")


class Test_class:
    def test_case2(self, connect):
        # print('fff')
        # print(dir(self))
        cursor = connect.cursor()
        sql = 'select count(1) from fund'
        cursor.execute(sql)
        rows = cursor.fetchone()
        result = rows[0]
        assert result == 11202

def test_case1(connect):
    cursor = connect.cursor()
    sql = 'select count(1) from fund'
    cursor.execute(sql)
    rows = cursor.fetchone()
    result = rows[0]
    assert result == 11202


if __name__ == '__main__':
    pytest.main(["-s", "test_huangcui.py", "--html=./report/result.html"])